package HLLib.base;

import HLCode.HLClass;
import HLCode.HLClassManager;
import HLCode.HLClassManager_H;
import HLCode.HLLibObject;

public class HLVirtualPad extends HLLibObject {
    public HLClass GetClass(HLClassManager classManager) {
        return classManager.GetLibClass(HLClassManager_H.CLASS_GROUP_TYPE_LIB_BASE, HLClassManager_H.LIB_CLASS_BASE_VirtualPad);
    }

    static private boolean enabled = false;

    static private HLList inputers = new HLList();

    static public void Start() {
        enabled = true;
    }

    static public void Stop() {
        enabled = false;
    }

    static public void pointerRefresh(HLList posList) {
        if (enabled) {
            for (int i = inputers.Count() - 1; i >= 0; i--) {
                ((HLIVirtualInputer) inputers.GetItem(i)).pointerRefresh(posList);
            }
        }
    }

    static public void update() {
        if (enabled) {
            for (int i = inputers.Count() - 1; i >= 0; i--) {
                ((HLIVirtualInputer) inputers.GetItem(i)).update();
            }
        }
    }

    static public void Add(HLIVirtualInputer virtualInputer) {
        inputers.Add(virtualInputer);
    }

    static public int Count() {
        return inputers.Count();
    }

    static public HLIVirtualInputer GetItem(int index) {
        return (HLIVirtualInputer) inputers.GetItem(index);
    }

    static public HLIVirtualInputer GetItemByID(int _id) {
        for (int i = inputers.Count() - 1; i >= 0; i--) {
            HLIVirtualInputer virtualInputer = (HLIVirtualInputer) inputers.GetItem(i);
            if (virtualInputer._id == _id) {
                return virtualInputer;
            }
        }
        return null;
    }

    static public void RemoveItemAt(int index) {
        inputers.RemoveAt(index);
    }

    static public void RemoveItemByID(int _id) {
        for (int i = inputers.Count() - 1; i >= 0; i--) {
            HLIVirtualInputer virtualInputer = (HLIVirtualInputer) inputers.GetItem(i);
            if (virtualInputer._id == _id) {
                inputers.RemoveAt(i);
            }
        }
    }

    static public void Clear() {
        inputers.Clear();
    }
}
